package team.seekers.hula.question.answerComment.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.question.answerComment.entity.vo.AnswerCommentListVO;
import team.seekers.hula.question.answerComment.service.AnswerCommentService;
import team.seekers.hula.question.answerComment.entity.dto.AnswerCommentQueryDTO;
import team.seekers.hula.question.answerComment.entity.dto.AnswerCommentAddDTO;
import team.seekers.hula.question.answerComment.entity.dto.AnswerCommentUpdateDTO;
import team.seekers.hula.question.answerComment.service.AnswerCommentGoodService;

/**
 * <p>
 * 回答的评论 前端控制器
 * </p>
 *
 * @author hbc
 * @since 2021-02-18
 */
@Controller
@ApiResponseBody
@RequestMapping("/answer/comment")
public class AnswerCommentController {

    @Autowired
    private AnswerCommentService answerCommentService;
    @Autowired
    private AnswerCommentGoodService answerCommentGoodService;

    @PostMapping("/add")
    public void add(@RequestBody AnswerCommentAddDTO answerCommentAddDTO){
        answerCommentService.add(answerCommentAddDTO);
    }

    @GetMapping("/delete")
    public void delete(@RequestParam("answerCommentId") String id){
        answerCommentService.delete(id);
    }


    @PostMapping("/update")
    public void update(@RequestBody AnswerCommentUpdateDTO updateVO){
        answerCommentService.update(updateVO);
    }

    // 分页查询
    @GetMapping("/page")
    public PageResult<AnswerCommentListVO> pageOrderByGoods(AnswerCommentQueryDTO answerCommentQueryDTO){
        return answerCommentService.page(answerCommentQueryDTO.getPageNow(),answerCommentQueryDTO.getPageSize(), answerCommentQueryDTO);
    }


    // 如果没点赞则点赞，如果点了则取消赞
    @GetMapping("/like/change")
    public void changeGood(@RequestParam String id){
        answerCommentGoodService.changeGood(id);
    }
}

